<template>
  <div class="moneylist">
    <div class="alllist">
      <table class="all_tb">
        <tr>
          <th>总金额</th>
          <th>总销售奖励</th>
          <th>总管理津贴</th>
          <th>总提现金额</th>
          <th>
            <div class="name_input">
              姓名：<input type="text" placeholder="姓名查询" v-model="wxm" />
            </div>
          </th>
          <th class="th_found">
            <router-link
              to=""
              tag="div"
              :class="'found'"
              @click.native="walletfound(wxm)"
            >
              <i class="el-icon-search"></i>查询
            </router-link>
          </th>
          <!--  @click.native="search"       @click.native="reset"  -->
          <th class="th_reset">
            <router-link to="" tag="div" :class="'reset'">
              <i class="el-icon-refresh-right"></i>重置
            </router-link>
          </th>
        </tr>
        <tr>
          <td>0</td>
          <td>0</td>
          <td>0</td>
          <td>0</td>
        </tr>
      </table>
    </div>

    <div class="money_tab">
      <router-link
        to="/walletlist/partnerlist"
        tag="div"
        :class="'hhr'"
        @click.native="dakehu()"
        >大客户</router-link
      >
      <router-link
        to="/walletlist/agencylist"
        tag="div"
        :class="'dl'"
        @click.native="hehuoren()"
        >合伙人</router-link
      >
      <router-link to="/agencylist" tag="button" :class="'excel'"
        >导出数据到Excel</router-link
      >
    </div>

    <!-- 表格 -->
    <router-view></router-view>

    <!-- 分页条 -->
    <div class="walletlist_fy">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage4"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="10"
        layout="total, sizes, prev, pager, next, jumper"
        :total="1"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import {Bus} from "../../Bus/index"
import {
  apiGetAgentSum,
  apiGetPartnerSum,
  apiGetKeyNameInfo,
  apiGetParNameInfo,
  apiGeWallettInfo,
  apiGetDateInOut,
} from "@/api/wallet";

export default {
  name: "MoneyList",
  components: {},
  created() {
    this.onload();
  },
  methods: {
    handleClick(row) {
      console.log(row);
    },

    // 分页
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },

    // 获取全部用户
    onload() {
      // apiGetAgentSum({}).then((res) => {
      //   console.log(res);
      // });
      // apiGetPartnerSum({}).then((res) => {
      //   console.log(res);
      // });
    },

    //通过昵称查询用户
    walletfound(val) {
      console.log(val);

      if (this.qiehuan == 0) {
        apiGetKeyNameInfo({
          name: val,
        }).then((res) => {
          console.log(res);

          this.tableData.agency_area=res.msg[0].province;

          // console.log( this.tableData.agency_area);
            Bus.$emit("tabledata",this.tableData.agency_area);
        });
      }
      if (this.qiehuan == 1) {
        apiGetParNameInfo({
          name: val,
        }).then((res) => {
          console.log(res);
        });
      }
    },

    //通过昵称查询合伙人

    // 大客户
    dakehu() {
      if (this.qiehuan == 0) {
        apiGetAgentSum({}).then((res) => {
          console.log(res);
          
          
          console.log(this.qiehuan);
        });
      }
    },

    // 合伙人
    hehuoren() {
      console.log(123);
      this.qiehuan = 1
      if ((this.qiehuan == 1)) {
        apiGetPartnerSum({}).then((res) => {
          console.log(res);
          console.log(this.qiehuan);
        });
      }
    },

    // 点击钱包明细
    // apiGeWallettInfo(val) {
    //   console.log(val);
    //   apiGeWallettInfo({
    //     nickname: val,
    //   }).then((res) => {
    //     console.log(res);
    //   });
    // },
  },

  data() {
    return {
      wxm: "",
      tableData: [{
         partnerid: '',
          name: "",
          tel: '',
          agency_level: "",
          agency_area: "",
          mange_benefit: '',
          cash_money: '',
          sale_incentive: '',
          total_money: '',
      }],

      // 分页
      currentPage4: 0,

      //
      qiehuan: 0,
    };
  },
};
</script>

<style scoped>

@import "../../style/css/WalletList.css";

</style>